
<html><HEAD>
<LINK REL=STYLESHEET HREF="default.css" TYPE="text/css">
<TITLE>
Using a Web service data source</TITLE>
</HEAD>
<BODY>

<!-- Header -->
<p class="ancestor" align="right"><A HREF="pbugp169.htm">Previous</A>&nbsp;&nbsp;<A HREF="pbugp171.htm" >Next</A>
<!-- End Header -->
<A NAME="CDCEEAJHWS"></A><h1>Using a Web service data source</h1>
<A NAME="TI5245"></A><h4>Presentation style requirement</h4>
<A NAME="TI5246"></A><p>You can
use a Web service as the data source for a DataWindow having any
of the following DataWindow presentation styles: </p>
<A NAME="TI5247"></A><table cellspacing=0 cellpadding=6 border=1 frame="void" rules="all"><tr><td  rowspan="1"  ><A NAME="TI5248"></A>Composite</td>
<td  rowspan="1"  ><A NAME="TI5249"></A>Graph</td>
<td  rowspan="1"  ><A NAME="TI5250"></A>Label</td>
<td  rowspan="1"  ><A NAME="TI5251"></A>TreeView</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5252"></A>Crosstab</td>
<td  rowspan="1"  ><A NAME="TI5253"></A>Grid</td>
<td  rowspan="1"  ><A NAME="TI5254"></A>N-Up</td>
<td  rowspan="1"  ><A NAME="TI5255"></A></td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5256"></A>Freeform</td>
<td  rowspan="1"  ><A NAME="TI5257"></A>Group</td>
<td  rowspan="1"  ><A NAME="TI5258"></A>Tabular</td>
<td  rowspan="1"  ><A NAME="TI5259"></A></td>
</tr>
</table>
<A NAME="TI5260"></A><p>Support for a Web service data source is not available for
RichText and OLE presentation styles, and it is only available in
the Enterprise edition of PowerBuilder.</p>
<A NAME="TI5261"></A><h4>Using the DataWindow wizard</h4>
<A NAME="TI5262"></A><p>After you select a supported DataWindow presentation style
from the DataWindow tab of the New dialog box, you select a data
source for the DataWindow.</p>
<A NAME="TI5263"></A><p>When you select Web Service as the data source and click Next,
the DataWindow wizard opens a page that prompts you to select a <ACRONYM title = "wisdull" >WSDL</ACRONYM> file. The file you select should
be in a publicly accessible location for all members of the development
team. You can enter the URL to a <ACRONYM title = "wisdull" >WSDL</ACRONYM>,
ASMX, or XML file, or you can browse a mapped drive for these types
of files. </p>
<A NAME="TI5264"></A><p>The Choose <ACRONYM title = "wissdull" >WSDL</ACRONYM> File
page of the DataWindow wizard also lets you name the assembly file
that the wizard will create. The assembly file serves as an interface
between the DataWindow and the Web service. If you do not name the
assembly file, the wizard will select a name for you based on the
name of the <ACRONYM title = "wisdull" >WSDL</ACRONYM> file entry.</p>
<A NAME="TI5265"></A><p>The next step to access a Web service data source is to select
a service described in the WSDL, and then one of its public methods.
You must then select a parameter for the DataWindow to use as the
result set for the method. </p>
<A NAME="TI5266"></A><p>A DataWindow typically obtains its data from an array of structures.
Because a Web service method can pass an array of structures in
one of its arguments rather than in a return value, the wizard prompts
you to select one of the method's arguments or its return
value as the designated result set for the method. If you want data
for a single row and column only, you can select a parameter that
has a simple datatype. You can also select a parameter that is an array
of simple datatypes rather than an array of structures.</p>
<A NAME="TI5267"></A><p>You complete the wizard as you would when using any other
type of data source for your DataWindow. After you complete the
wizard, the DataWindow displays in the DataWindow painter. However,
there is no equivalent to the <ACRONYM title = "sequel" >SQL</ACRONYM> painter
for a DataWindow with a Web service data source. For this type of
DataWindow, you cannot select Design&gt;Data Source from the
DataWindow painter menu to change selected columns or modify the
DataWindow syntax.</p>
<p><img src="images/note.gif" width=17 height=17 border=0 align="bottom" alt="Note"> <span class=shaded>Runtime requirements on a deployment computer</span> <A NAME="TI5268"></A>To run the Web service DataWindow application from a deployment
computer, the assembly file that you generate with the wizard must
be copied along with the application executable and required PowerBuilder runtime
DLLs for Web service applications. For information on the required
DLLs and the Runtime Packager tool that you can use to deploy them,
see "Deploying Applications and Components" in <i>Application
Techniques</i>
.</p>
<A NAME="TI5269"></A><p>For information on rebuilding an assembly generated by the
DataWindow wizard, see <A HREF="pbugp196.htm#CHDIEDFB">"Regenerating an assembly "</A>.</p>
<A NAME="TI5270"></A><h4>Datatype mappings</h4>
<A NAME="TI5271"></A><p><A HREF="pbugp170.htm#CDCIABIE">Table 18-6</A> lists <ACRONYM title = "dot net" >.NET</ACRONYM> datatypes and the DataWindow
datatypes to which they map when you use a <ACRONYM title = "dot net" >.NET</ACRONYM> Web
service as a data source. Arrays are also supported for these datatypes
except for System.Byte.</p>
<A NAME="CDCIABIE"></A><table cellspacing=0 cellpadding=6 border=1 frame="void" rules="all"><caption>Table 18-6: Datatype mapping for <ACRONYM title = "dot net" >.NET</ACRONYM> datatypes</caption>
<tr><th  rowspan="1"  ><A NAME="TI5272"></A><ACRONYM title = "dot net" >.NET</ACRONYM> datatype</th>
<th  rowspan="1"  ><A NAME="TI5273"></A>DataWindow datatype</th>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5274"></A>System.Boolean</td>
<td  rowspan="1"  ><A NAME="TI5275"></A>long (Handled as a boolean at runtime.)</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5276"></A>System.Byte</td>
<td  rowspan="1"  ><A NAME="TI5277"></A>ulong</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5278"></A>System.DateTime</td>
<td  rowspan="1"  ><A NAME="TI5279"></A>datetime (Minimum and maximum dates for
.NET can be outside the range of dates supported by PowerBuilder. PowerBuilder does
not support dates prior to the year 1000 or after the year 3000.)</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5280"></A>System.Decimal</td>
<td  rowspan="1"  ><A NAME="TI5281"></A>decimal</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5282"></A>System.Double</td>
<td  rowspan="1"  ><A NAME="TI5283"></A>number</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5284"></A>System.Int16</td>
<td  rowspan="1"  ><A NAME="TI5285"></A>long</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5286"></A>System.Int32</td>
<td  rowspan="1"  ><A NAME="TI5287"></A>long</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5288"></A>System.Int64</td>
<td  rowspan="1"  ><A NAME="TI5289"></A>decimal</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5290"></A>System.SByte</td>
<td  rowspan="1"  ><A NAME="TI5291"></A>long</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5292"></A>System.Single</td>
<td  rowspan="1"  ><A NAME="TI5293"></A>real</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5294"></A>System.String</td>
<td  rowspan="1"  ><A NAME="TI5295"></A>string(40)</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5296"></A>System.UInt16</td>
<td  rowspan="1"  ><A NAME="TI5297"></A>ulong</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5298"></A>System.UInt32</td>
<td  rowspan="1"  ><A NAME="TI5299"></A>ulong</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI5300"></A>System.UInt64</td>
<td  rowspan="1"  ><A NAME="TI5301"></A>decimal</td>
</tr>
</table>
<A NAME="TI5302"></A><p>The DataWindow can also use a Web service data source that
has structures for parameters, as long as the structures are composed
of the simple datatypes that can be mapped to DataWindow datatypes.
An array of structures can be mapped to <i>n</i> rows
with <i>x</i> columns where <i>n</i> is
the size of the array and <i>x</i> is the number of
members in the structure. Nested structures are not supported. </p>
<A NAME="TI5303"></A><h4>Using parameters by reference</h4>
<A NAME="TI5304"></A><p>For a Web service that you create from a PowerBuilder nonvisual
object, a result set must be passed by reference, but it cannot
be passed in a method return value. You must use a method argument
to pass the result set and then select that argument in any DataWindow
object that uses the method as its data source.</p>
<A NAME="TI5305"></A><p>A parameter passed by reference is a bidirectional [IN,OUT] parameter
by definition. The Web Service DataWindow wizard lets you select
a Web service method [OUT] or [IN,OUT] parameter,
instead of the method return value, to pass a result set to a DataWindow
object. However, the parameter you select cannot be used for both
a return value and a retrieval argument by the same DataWindow object. </p>
<A NAME="TI5306"></A><h4>Database-related functions and events</h4>
<A NAME="TI5307"></A><p>In the Web Service DataWindow, some database or transaction-related functions
and events are not supported and meaningless because the Web Service
DataWindow has no direct relation to the database. The following functions
cannot be used with the Web Service DataWindow: <b>GetSQLPreview</b>, <b>GetSQLSelect</b>, <b>SetSQLPreview</b>, <b>SetSQLSelect</b>, <b>SetTrans</b>,
and <b>SetTransObject</b>.</p>
<A NAME="TI5308"></A><p>The DBError event is also not supported for the Web Service
DataWindow. Instead, you can use the WSError error event to handle
errors during retrieve, insert, or update operations. </p>
<A NAME="TI5309"></A><h4>Using the WSConnection object</h4>
<A NAME="TI5310"></A><p>Some Web services support or require a user ID and password,
and other session-related properties like firewall settings. The WSConnection
object can provide this information for your DataWindow connections.</p>
<A NAME="TI5311"></A><p>You use an instance of the WSConnection object to connect
to a Web service by calling the <b>SetWSObject</b> method. </p>
<A NAME="TI5312"></A><p>The following code instantiates a WSConnection object with
user-related and authentication information, then sets the object
as the connection object for a Web service data source:<p><PRE> int ii_return</PRE><PRE> wsconnection ws_1</PRE><PRE> ws_1 = create wsconnection</PRE><PRE> ws_1.username = "johndoe"</PRE><PRE> ws_1.password = "mypassword"</PRE><PRE> ws_1.endpoint = "myendpoint"</PRE><PRE> ws_1.authenticationmode = "basic"</PRE><PRE> ws_1.usewindowsintegratedauthentication = true</PRE><PRE> ii_return = dw_1.setwsobject (ws_1)</PRE></p>
<A NAME="TI5313"></A><p>For more information about setting properties for a Web service
connection, see WSConnection and <b>SetWSObject</b> in
the online Help. </p>
<A NAME="TI5314"></A><p>For more information about updating the database with a Web
service DataWindow, see <A HREF="pbugp196.htm#CHDEJJJE">"Using a Web service to update
the database"</A>.</p>

